<template>
  <div>
    <toyFactory ref="factory" />
    <div>
      <div>书籍：{{ book }}，玩具：{{ toy }}</div>
      <button @click="getBook">获取书籍</button>
      <button @click="getToy">获取玩具</button>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import toyFactory from './toyFactory.vue'

let factory = ref()

let book = ref('')
let toy = ref('')

function getBook() {
  book.value = factory.value.book
}

function getToy() {
  toy.value = factory.value.toy
  console.log("toy", toy.value)
}
</script>

<style lang="scss" scoped>

</style>